package org.leanr.spring5.service;


import org.leanr.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 类上增加创建对象的注解
 * - @Componet
 * - @Service
 * - @Controller
 * - @Repository
 * value属性可以不设置，默认是类的名称，首字母小写，
 */
@Service(value = "userService")
public class UserService {
    //注入属性的注解@Autowired，根据属性类型自动装入
    //@Autowired
    //@Qualifier(value = "userDaoImpl2")
    @Resource
    private UserDao userDao;
    @Value(value = "zhangsan")
    private String userName;
    public void add(){
        System.out.println("userService add");
        System.out.println(userName);
        userDao.add();
    }
}
